

import java.util.Scanner;

public class LogIn {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入cno");
        String cno=scanner.next();
        System.out.println("请输入课程名字");
        String cname=scanner.next();
        System.out.println("请输入学分");
        double credit=scanner.nextDouble();
        Course course=new Course(cno,cname,credit);
        try {
            if(!(course.getCredit()>=0.5&&course.getCredit()<=6)){
                throw new CreditException("课程的学分应在0.5到6之间");
            }else{
                System.out.println("输入成功学分为："+course.getCredit());
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
class Course{
    private String cno;
    private String cname;
    private double credit;
    public Course(String cno, String cname, double credit) {
        this.cno = cno;
        this.cname = cname;
        this.credit = credit;
    }
    public Course() {
    }
    public String getCno() {
        return cno;
    }
    public void setCno(String cno) {
        this.cno = cno;
    }
    public String getCname() {
        return cname;
    }
    public void setCname(String cname) {
        this.cname = cname;
    }
    public double getCredit() {
        return credit;
    }
    public void setCredit(double credit) {
        this.credit = credit;
    }

}

class CreditException extends RuntimeException{
    public CreditException(String message){
        super(message);
    }
}